<% layout('/layout/default.html', {title: '日志查询', libs: ['dataGrid']}){ %>
<div class="main-content">
		<div class="card-header">
				<i class="fa fa-sitemap"></i> 日志查询
			<div class="header-tools float-right">
				<a href="#" class="btn btn-sm btn-secondary" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
				<a href="#" class="btn btn-sm btn-secondary" id="btnRefresh" title="刷新"><i class="fa fa-refresh"></i> 刷新</a>
			</div>
		</div>
		<div class="container-fluid">
			<form id="searchForm" action="${ctx}/sys/log/listData" class="form-inline d-none">
				<div class="form-group">
					<label class="control-label">操作菜单:</label>
					<div class="control-inline">
						<input name="title" maxlength="64" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">用户ID: </label>
					<div class="control-inline">
						<input name="createBy.id"  maxlength="5" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">URI：</label>
					<div class="control-inline">
						<input name="requestUri" maxlength="11" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">日期范围：</label>
					<div class="control-inline">
						<input name="beginDate"  onClick="WdatePicker()"  maxlength="30" class="form-control"/>
						<input name="endDate"  onClick="WdatePicker()" maxlength="30" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">只查询异常信息:</label>
					<div class="control-inline">
						<input name="exception" type="checkbox" />
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary ">查询</button>
					<button type="reset" class="btn btn-secondary ">重置</button>
				</div>
			</form>			
			<table id="btGrid"></table>
		</div>
</div>
<% } %>
<script>
//初始化DataGrid对象
	$('#btGrid').BTGrid({
		searchForm: $("#searchForm"),
		subGrid: true,
		subGridRowExpanded: showChildGrid,
		columnModel: [
			{title:'操作菜单', field:'title', width:100, align:"center"},
			{title:'操作用户', field:'operatorName', width:50, align:"center"},
			{title:'所在公司', field:'companyName', width:60, align:"center"},
			{title:'所在部门', field:'deptName', width:50, align:"center"},
			{title:'URI', field:'requestUri', width:100, align:"center"},
			{title:'提交方式', field:'method', width:50, align:"center"},
			{title:'操作者IP', field:'remoteAddr', width:80, align:"center"},
			{title:'操作时间', field:'createDate', width:60, align:"center",formatter:"date"},
			{title:'异常信息', field:'exception', width:50, align:"center",formatter:function(val, row, index){
				 return val==""?"无":"有";
			}}
		],
		// 加载成功后执行事件
		ajaxSuccess: function(data){
			
		}
	});
	
	function showChildGrid(parentRowID,parentRowKey){
			//显示异常信息内容
		 $.ajax({
             url: '${ctx}/sys/log/form',
             type: "post",
             data:{'id':parentRowKey},
             datatype:'json',
             success: function (data) {
            	 var html = data.exception==""?"无异常日志记录":data.exception;
            	 $("#" + parentRowID).append(html);
             }
         });
	}
</script>